using System;

using MettleSystems.dashCommerce.Core;
using OpenNetCommerce.Localization;
using SubSonic.Utilities;

namespace MettleSystems.dashCommerce.Web.admin {

  public partial class errorlogdetails : MettleSystems.dashCommerce.Controls.AdminPage {

    #region Member Variables

    private int logId = 0;

    #endregion

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        logId = Utility.GetIntParameter("logId");
        if (logId > 0) {
          SetErrorLogDetailsProperties();
          Log log = new Log(logId);
          lblLogDateDisplay.Text = log.LogDate.ToLongDateString();
          lblLogLevelDisplay.Text = ((Logger.LogMessageType)Convert.ToInt32(log.MessageType.ToString())).ToString();
          lblLogMessageDisplay.Text = log.Message;
          lblLogScriptNameDisplay.Text = log.ScriptName;
          lblAuthenticatedUserDisplay.Text = log.AuthUser;
          lblRemoteHostDisplay.Text = log.RemoteHost;
          lblUserAgentDisplay.Text = log.UserAgent;
          lblReferrerDisplay.Text = log.Referer;
          lblExceptionTypeDisplay.Text = log.ExceptionType;
          lblExceptionMessageDisplay.Text = log.ExceptionMessage;
          lblQueryStringDataDisplay.Text = log.QueryStringData;
          txtLogInfoDisplay.Text = log.ExceptionStackTrace;
        }
      }
      catch (Exception ex) {
        Logger.Error(typeof(errorlogdetails).Name + ".Page_Load", ex);
        Master.MessageCenter.DisplayCriticalMessage(ex.Message);
      }
    }

    #endregion

    #region Methods

    #region Private

    /// <summary>
    /// Sets the error log details properties.
    /// </summary>
    private void SetErrorLogDetailsProperties() {
      
      
      
      
      
      lblLogScriptName.Text = LocalizationUtility.GetText("hdrScriptName");
      lblReferrer.Text = LocalizationUtility.GetText("hdrReferrer");
      lblUserAgent.Text = LocalizationUtility.GetText("hdrUserAgent");
      lblAuthenticatedUser.Text = LocalizationUtility.GetText("hdrAuthenticatedUser");
      lblRemoteHost.Text = LocalizationUtility.GetText("hdrRemoteHost");
      lblExceptionType.Text = LocalizationUtility.GetText("hdrExceptionType");
      lblExceptionMessage.Text = LocalizationUtility.GetText("hdrExceptionMessage");
      lblQueryStringData.Text = LocalizationUtility.GetText("hdrQueryStringData");
    }

    #endregion

    #endregion

  }
}
